<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Language" content="en-us" />
		
		<title>Element Additions</title>
		
		<meta http-equiv="imagetoolbar" content="no" />
		<meta name="MSSmartTagsPreventParsing" content="true" />
		<meta name="Copyright" content="(c) 2007 Copyright content:  Copyright design: Luke Sutton" />
		
		<link rel="stylesheet" href="test.css" type="text/css" media="screen" charset="utf-8">
		
		<script type="text/javascript" language="javascript" charset="utf-8" src="../lib/prototype.js"></script>
		<script type="text/javascript" language="javascript" charset="utf-8" src="../lib/unittest.js"></script>
		<script type="text/javascript" language="javascript" charset="utf-8" src="../src/element_additions.js"></script>
		
	</head>
	
	<body>	
	
    <h1>Element Additions</h1>
		<div id="testlog"></div>
		<script type="text/javascript" charset="utf-8">
		  new Test.Unit.Runner({
		    testAddBefore: function() { with(this) {
		      $('target').addBefore('<p id="insertBeforeString">Text before (string)</p>');
		      // DOM NODE
		      var tag = document.createElement('p');
		      tag.id = 'insertBeforeNode';
		      tag.appendChild(document.createTextNode('Text before (dom node)'));
		      $('target').addBefore(tag);
		      // ASSERT FTW
		      assertNotNull($('insertBeforeString'));
		      assertNotNull($('insertBeforeNode'));
		      assertEqual($('target'), $('insertBeforeNode').next());
		      assertEqual($('insertBeforeNode'), $('insertBeforeString').next());
		    }},
		    testAddAfter: function() { with(this) {
		      $('target').addAfter('<p id="addAfterString">Text after (string)</p>');
		      // DOM NODE
		      var tag = document.createElement('p');
		      tag.id = 'addAfterNode';
		      tag.appendChild(document.createTextNode('Text after (DOM node)'));
		      $('target').addAfter(tag);
		      assertNotNull($('addAfterString'));
		      assertNotNull($('addAfterNode'));
		      assertEqual($('target'), $('addAfterNode').previous());
		      assertEqual($('addAfterNode'), $('addAfterString').previous());
		    }},
		    testAddAtStart: function() { with(this) {
		      $('target').addAtStart('<li id="addAtStartString">At the start (string))</li>');
		      var stringTest = $('addAtStartString');
		      assertNotNull(stringTest);
		      assertEqual($('firstEntry'), stringTest.next());
		      stringTest.remove();
		      // DOM NODE
		      var tag = document.createElement('li');
		      tag.id = 'addAtStartNode';
		      tag.appendChild(document.createTextNode('At at the start (DOM node)'));
		      $('target').addAtStart(tag);
		      var nodeTest = $('addAtStartNode');
		      assertNotNull(nodeTest);
		      assertEqual($('firstEntry'), nodeTest.next());
		    }},
		    testAddAtEnd: function() { with(this) {
		      $('target').addAtEnd('<li id="addAtEndString">At the end (string))</li>');
		      var stringTest = $('addAtEndString');
		      assertNotNull(stringTest);
		      assertEqual($('lastEntry'), stringTest.previous());
		      stringTest.remove();1
		      // DOM NODE
		      var tag = document.createElement('li');
		      tag.id = 'addAtEndNode';
		      tag.appendChild(document.createTextNode('At at the end (DOM node)'));
		      $('target').addAtEnd(tag);
		      var nodeTest = $('addAtEndNode');
		      assertNotNull(nodeTest);
		      assertEqual($('lastEntry'), nodeTest.previous());
		    }},
		    testAddAt: function() { with(this) {
		      $('target').addAt('<li id="addAtString">At the end (string))</li>', 1);
		      var stringTest = $('addAtString');
		      assertNotNull(stringTest);
		      assertEqual($('target').immediateDescendants()[1], stringTest);
		    }}
		  });
		</script>
				
		<ul id="target">
		  <li id="firstEntry">A list to test some insertions</li>
		  <li>So some bogus entries</li>
		  <li id="lastEntry">Would work nice!</li>
		</ul>
	
	</body>
</html>
